$(document).ready(function(){
	$("#save").click(function () {
		
		$(".error").hide();
	  var hasError = false;
      var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
      var phoneReg = /^(\+33\.|0)[0-9]{9}$/;
      var emailaddressVal = $("#u_email").val();
      var phoneVal = $("#u_phonenumber").val();
      
      
      if(phoneVal == '') {
          $("#u_phonenumber").after('<br><span class="error" style ="color: red;">Veuillez saisir un numero de t\351l\351phone.</span>');
          hasError = true;
      }
      
      if(!phoneReg.test(phoneVal)) {
          $("#u_phonenumber").after('<br><span class="error" style ="color: red;">Veuillez saisir un numero de t\351l\351phone valide.</span><br>');
          hasError = true;
      }
      if(emailaddressVal == '') {
          $("#u_email").after('<br><span class="error" style ="color: red;">Veuillez saisir votre adresse e-mail.</span>');
          hasError = true;
      }
      else if(!emailReg.test(emailaddressVal)) {
          $("#u_email").after('<br><span class="error" style ="color: red;">Veuillez saisir votre adresse e-mail valide.</span><br>');
          hasError = true;
      }
      
      if(hasError == false){
//        	$("#temp").show();
//        	$("#temp2").show();
        	$('html,body').animate({scrollTop: 0});
        	}

        if(hasError == true) { 
        	return false; 
        	}
        
	});
});